package aim.orderentry;

import aim.orderentry.business.GetLocationReceiver;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class MainActivity extends MapActivity {

	private static MapView 		mMapView; 
	private MapController 	mMapController;
//	private LocationManager locationManager;
	
	private GetLocationReceiver getLocationer;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		mMapView = (MapView) findViewById(R.id.mapView);
		mMapView.setBuiltInZoomControls(true);
		mMapController = mMapView.getController();
		mMapController.setZoom(16);
		getLocationer = new GetLocationReceiver();
		getLocationer.setAlarm(10, this);
//		locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
//		locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000,	 10, listener);
	}

	@Override
	protected void onStop() {
		super.onStop();
		getLocationer.cancelAlarm(this);
	}
	
//	private LocationListener listener = new LocationListener() {
//		
//		@Override
//		public void onStatusChanged(String provider, int status, Bundle extras) {
//			
//		}
//		
//		@Override
//		public void onProviderEnabled(String provider) {
//			// TODO Auto-generated method stub
//			
//		}
//		
//		@Override
//		public void onProviderDisabled(String provider) {
//			
//		}
//		
//		@Override
//		public void onLocationChanged(Location location) {
//			mMapController.animateTo(new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)));
//			Toast.makeText(MainActivity.this, "Long : " + location.getLongitude(), Toast.LENGTH_LONG).show();
//		}
//	};
	
	public static MapView getMapView() {
		return mMapView;
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}


	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
